<?php

namespace app\admin\model\scanwork;

use think\Model;

class Progress extends Model
{
    // 表名
    protected $name = 'scanwork_progress';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text'
    ];
    
    public function getStatusList()
    {
        return ['pending' => __('Pending'), 'in_progress' => __('In_progress'), 'completed' => __('Completed')];
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id');
    }

    public function order()
    {
        return $this->belongsTo('Order', 'order_id', 'id');
    }

    public function allocation()
    {
        return $this->belongsTo('Allocation', 'allocation_id', 'id');
    }
} 